#!/bin/sh
set -ev

# Directories.
root_dir=`pwd`
build_dir="$root_dir/_travis/build"
console_bridge_dir="$build_dir/console_bridge"
urdfdom_headers_dir="$build_dir/urdfdom_headers"

# Shortcuts.
git_clone="git clone --quiet --recursive"

# create locale for testing
sudo locale-gen nl_NL.UTF-8

# Create layout.
rm -rf "$build_dir"
mkdir -p "$build_dir"

# Retrieve console_bridge
echo "--> Compiling console_bridge"
cd "$build_dir"
$git_clone "git://github.com/ros/console_bridge.git"
cd "$console_bridge_dir"
cmake .
sudo make install

# Retrieve urdfdom_headers
echo "--> Compiling urdfdom_headers"
cd "$build_dir"
$git_clone "git://github.com/ros/urdfdom_headers.git"
cd "$urdfdom_headers_dir"
cmake .
sudo make install

# Compile
echo "--> Compiling urdfdom"
cd "$root_dir"
cmake .
make
make test ARGS="-VV"
sudo make install
